//
//  PollingDetailView.m
//  OperationPro
//
//  Created by yaxue wang on 2017/1/5.
//  Copyright © 2017年 展鸿科技. All rights reserved.
//

#import "PollingDetailView.h"
#import "PollingDetailCell.h"
#import "PollingPhoneView.h"
#import "LoadingView.h"
@interface PollingDetailView()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UIView* startView;
@property(nonatomic,strong)UITableView* listView;
@property(nonatomic,strong)UIView* environmentView;
@property(nonatomic,strong)UIView*networkView;
@property(nonatomic,strong)UIView*serverView;
@property(nonatomic,strong)UIView*ideaView;
@property(nonatomic,strong)NSMutableArray*dataArray;
@property(nonatomic,strong)NSString*Uuid;
@property(nonatomic,strong)NSString*suggestionString;
@property(nonatomic,strong)NSString*code;//单号
@property(nonatomic,strong)NSString*instName;
@property(nonatomic,strong)NSString*starTime;
@property(nonatomic,strong)NSString*endTime;
@property (nonatomic,strong)NSMutableArray *unusualAr;
@property(nonatomic,strong)NSMutableArray*moblieArray;
@property(nonatomic,strong)NSMutableArray*tableArray;

@end
@implementation PollingDetailView
-(instancetype)initWithFrame:(CGRect)frame withWarningUuid:(NSString *)warningUuid {
    self = [super initWithFrame:frame];
    if (self) {
        self.Uuid=warningUuid;
        self.tableArray=[[NSMutableArray alloc]init];
        self.dataArray=[[NSMutableArray alloc]init];
        self.unusualAr=[[NSMutableArray alloc]init];
        self.moblieArray=[[NSMutableArray alloc]init];
        self.backgroundColor=BackColor;
        [CClass HttpRequestTask:YES withUrl:@"inspection_getInfo" withData:@{@"uuid":self.Uuid} notifyError:YES onSuccess:^(BaseModel *model) {
            //状态
            if([F_NSpace([model.B_data objectForKey:@"state"]) isEqualToString:@""]){
                
            }else
            {
                self.stateNum=[[model.B_data objectForKey:@"state"] integerValue];
                
            }

            NSMutableArray*array=[model.B_data objectForKey:@"contacts"];
    
            for (int i=0; i<array.count; i++) {
                NSMutableDictionary *dic=[array objectAtIndex:i];
                if([F_NSpace([dic objectForKey:@"contact_mobile"]) isEqualToString:@""]){
                    
                }else
                {
                    NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
                    [dataDic setObject:[dic objectForKey:@"contact_mobile"]forKey:@"mobile"];
                    [dataDic setObject:[dic objectForKey:@"contact_name"]forKey:@"name"];
                    [self.moblieArray addObject:dataDic];
                }
                
                
            }

            //单号
            if([F_NSpace([model.B_data objectForKey:@"code"]) isEqualToString:@""]){
                self.code=@"";
                
            }else
            {
                self.code=[model.B_data objectForKey:@"code"];
                
            }
            //机构
            if([F_NSpace([model.B_data objectForKey:@"inst_name"]) isEqualToString:@""]){
                self.instName=@"";
                
            }else
            {
                self.instName=[model.B_data objectForKey:@"inst_name"];
                
            }
            //开始时间
            if([F_NSpace([model.B_data objectForKey:@"start_time"]) isEqualToString:@""]){
                self.starTime=@"";
                
            }else
            {
                NSString *timeString = [[model.B_data objectForKey:@"start_time"]  substringWithRange:NSMakeRange(0, 16)];
                self.starTime=timeString;
                
            }
            //结束时间
            if([F_NSpace([model.B_data objectForKey:@"end_time"]) isEqualToString:@""]){
                self.endTime=@"";
                
            }else
            {
                NSString *timeString = [[model.B_data objectForKey:@"end_time"]  substringWithRange:NSMakeRange(0, 16)];
                
                self.endTime=timeString;
                
            }
            if (self.stateNum==1||self.stateNum==2) {
                //1 没有接单的时候 2 没有处理的时候
                [self createStartView];
                
            }else if (self.stateNum==10||self.stateNum==11||self.stateNum==20||self.stateNum==90||self.stateNum==99||self.stateNum==98)//10处理中 20待确认 11被退回 90待评价 99已完成 98已撤销
            {
                [self createListView];
                
            }

            
            
        } onError:^(BaseModel *model) {
            
        }];
      
    }
    return self;
    
}
- (void)createListView
{
    _listView=[[UITableView alloc]initWithFrame:CGRectMake(0, 10, WindowWidth, self.bounds.size.height-10)];
    _listView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _listView.delegate=self;
    _listView.dataSource=self;
    _listView.backgroundColor=BackColor;
    [_listView registerClass:[PollingDetailCell class] forCellReuseIdentifier:@"cell"];
    [self addSubview:_listView];
    [self getData];
   

}

- (void)getData
{
    //详情请求
    [[LoadingView shareLoading] startAnimating];
    [CClass HttpRequestTask:YES withUrl:@"inspection_getReportSummary" withData:@{@"uuid":self.Uuid} notifyError:YES onSuccess:^(BaseModel *model) {
        self.dataArray=(NSMutableArray*)[model.B_data objectForKey:@"level_one"];
        [self.tableArray removeAllObjects];
        [self.tableArray addObjectsFromArray:self.dataArray];
        NSMutableArray*array=[model.B_data objectForKey:@"contacts"];
        [self.moblieArray removeAllObjects];
        for (int i=0; i<array.count; i++) {
            NSMutableDictionary *dic=[array objectAtIndex:i];
            if([F_NSpace([dic objectForKey:@"contact_mobile"]) isEqualToString:@""]){
                
             }else
             {
                 NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
                 [dataDic setObject:[dic objectForKey:@"contact_mobile"]forKey:@"mobile"];
                 [dataDic setObject:[dic objectForKey:@"contact_name"]forKey:@"name"];
                 [self.moblieArray addObject:dataDic];
             }
           

        }
        //状态
        if([F_NSpace([model.B_data objectForKey:@"state"]) isEqualToString:@""]){
            
        }else
        {
            self.stateNum=[[model.B_data objectForKey:@"state"] integerValue];
            
        }
        //单号
        if([F_NSpace([model.B_data objectForKey:@"code"]) isEqualToString:@""]){
            self.code=@"";
            
        }else
        {
            self.code=[model.B_data objectForKey:@"code"];
            
        }
        //机构
        if([F_NSpace([model.B_data objectForKey:@"inst_name"]) isEqualToString:@""]){
            self.instName=@"";
            
        }else
        {
            self.instName=[model.B_data objectForKey:@"inst_name"];
            
        }
        //开始时间
        if([F_NSpace([model.B_data objectForKey:@"start_time"]) isEqualToString:@""]){
            self.starTime=@"";
            
        }else
        {
            NSString *timeString = [[model.B_data objectForKey:@"start_time"]  substringWithRange:NSMakeRange(0, 16)];
            self.starTime=timeString;
            
        }
        //结束时间
        if([F_NSpace([model.B_data objectForKey:@"end_time"]) isEqualToString:@""]){
            self.endTime=@"";
            
        }else
        {
            NSString *timeString = [[model.B_data objectForKey:@"end_time"]  substringWithRange:NSMakeRange(0, 16)];
            
            self.endTime=timeString;
            
        }
        NSString *is_completed;
        //建议
        if([F_NSpace([model.B_data objectForKey:@"suggestion"]) isEqualToString:@""]){
            self.suggestionString=@"";
            is_completed=@"0";
        }else
        {
            self.suggestionString=[model.B_data objectForKey:@"suggestion"];
            is_completed=@"1";

        }
        [self.tableArray addObject:@{@"name":@"意见与建议",@"is_completed":is_completed}];

        if(self.stateNum==10||self.stateNum==11)
        {//处理中没有生成报告 退回和待处理
            int j=0;
            
            for (int i=0; i<self.dataArray.count; i++) {
                NSDictionary *dic=[self.dataArray objectAtIndex:i];
                if ([[dic objectForKey:@"is_completed"] integerValue]==1) {
                    j++;
                    
                }else
                {
                    j=1000;
                    
                }
                
            }
            
            if(j==self.dataArray.count)
            {
                //全部填完 能生成
                _listView.tableFooterView= [self producefootTableView];
            }else
            {
                //有没有填写完的 不能生成
                
                _listView.tableFooterView= [self noProducefootTableView];
                
            }
            [_listView reloadData];

        }else if (self.stateNum==20)//待确认
        {
            //显示确认界面
            _listView.tableFooterView= [self confirmFootTableView];
            [_listView reloadData];
    } else if (self.stateNum==99||self.stateNum==90)//已完成、待评价
     {
         //判断有无异常
         [CClass HttpRequestTask:YES withUrl:@"inspection_getExceptionReport" withData:@{@"uuid":self.Uuid} notifyError:YES onSuccess:^(BaseModel *model) {
             self.unusualAr=(NSMutableArray*)[model.B_data objectForKey:@"list"];
             if (self.unusualAr.count>0) {
                 _listView.tableHeaderView=[self headView];
             }else
             {
                 _listView.tableHeaderView=[self headView1];

             }
             //完成界面 有结束时间
             _listView.tableFooterView= [self completeFootView];
             [_listView reloadData];
         } onError:^(BaseModel *model) {
             
         }];
         
      
     }
        [[LoadingView shareLoading] stopAnimating];
 
    } onError:^(BaseModel *model) {
        [[LoadingView shareLoading] stopAnimating];

    }];

    

}
- (void)refrshData
{
  
    [self getData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return self.tableArray.count;
 
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    PollingDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[PollingDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
     if(self.stateNum==10||self.stateNum==11||self.stateNum==20)
     {//处理中没有生成报告

             NSMutableDictionary *dic=[self.tableArray objectAtIndex:indexPath.row];
             cell.nameLab.text=[dic objectForKey:@"name"];
             //0 为没有填完 1为填完
             if ([[dic objectForKey:@"is_completed"] integerValue] ==0) {
                 UIImage *successImage=[UIImage imageNamed:@""];
                 cell.successImg.image=successImage;
             }else
             {
                 UIImage *successImage=[UIImage imageNamed:@"Ico_input_success"];
                 cell.successImg.image=successImage;
             }

     }else if(self.stateNum==98||self.stateNum==99||self.stateNum==90)
     {//历史的数据
         cell.successImg.image=[UIImage imageNamed:@""];
             NSMutableDictionary *dic=[self.tableArray objectAtIndex:indexPath.row];
             cell.nameLab.text=[dic objectForKey:@"name"];
             

     }else
     {
         UIImage *successImage=[UIImage imageNamed:@"Ico_input_success"];
         cell.successImg.image=successImage;
        NSMutableDictionary *dic=[self.tableArray objectAtIndex:indexPath.row];
        cell.nameLab.text=[dic objectForKey:@"name"];
 
     }
    
    return cell;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 44;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.stateNum==98||self.stateNum==99||self.stateNum==90||self.stateNum==20) {
        
        //调到不可以编辑的界面
        if (indexPath.row<self.dataArray.count) {
            NSMutableDictionary *dic=[self.dataArray objectAtIndex:indexPath.row];
            NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
            [dataDic setObject:[dic objectForKey:@"name"] forKey:@"name"];
            [dataDic setObject:[dic objectForKey:@"uuid"] forKey:@"uuid"];
            [dataDic setObject:[NSString stringWithFormat:@"%d",[[dic objectForKey:@"order_no"] integerValue]] forKey:@"order_no"];
            NSString * unusualNum;//有异常为1没有异常为0
            if(self.unusualAr.count>0)
            {
                //有异常
                unusualNum=@"1";
            }else
            {
                unusualNum=@"0";
                
            }
            if (self.gotoTableComplete) {
                self.gotoTableComplete(unusualNum,dataDic,self.dataArray);
            }
        }else
        {
            //意见与建议
            NSString * unusualNum;//有异常为1没有异常为0
            if(self.unusualAr.count>0)
            {
                //有异常
                unusualNum=@"1";
            }else
            {
                unusualNum=@"0";
                
            }
            //为了跳转到上一页 需要最后一个的值
            NSMutableDictionary *dic=[self.dataArray objectAtIndex:indexPath.row-1];
            NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
            [dataDic setObject:[dic objectForKey:@"name"] forKey:@"name"];
            [dataDic setObject:[dic objectForKey:@"uuid"] forKey:@"uuid"];
            [dataDic setObject:[NSString stringWithFormat:@"%d",[[dic objectForKey:@"order_no"] integerValue]] forKey:@"order_no"];
            
            
            if (self.gotoIdeaComplete) {
                self.gotoIdeaComplete(unusualNum,dataDic,self.dataArray);
                
            }
        }
        
    }else
    {
        
        //跳转到可以编辑的界面
        if (indexPath.row<self.dataArray.count) {
            NSMutableDictionary *dic=[self.dataArray objectAtIndex:indexPath.row];
            NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
            [dataDic setObject:[dic objectForKey:@"name"] forKey:@"name"];
            [dataDic setObject:[dic objectForKey:@"uuid"] forKey:@"uuid"];
            [dataDic setObject:[NSString stringWithFormat:@"%d",[[dic objectForKey:@"order_no"] integerValue]] forKey:@"order_no"];
            //is_completed 0 为没有填完 1为填完
            NSString * isEdit=[NSString stringWithFormat:@"%d",[[dic objectForKey:@"is_completed"] integerValue]];
            [dataDic setObject:isEdit forKey:@"isEdit"];
            //意见与建议
            NSString * num;
            if ([self.suggestionString isEqualToString:@""]) {
                num=@"0";
            }else
            {
                num=@"1";
                
            }
                if (self.gotoTableEdit) {
                self.gotoTableEdit(num,dataDic,self.dataArray);
            }
        }else
        {
            //意见与建议
            NSString * num;
            if ([self.suggestionString isEqualToString:@""]) {
                num=@"0";
            }else
            {
                num=@"1";
                
            }
                //为了跳转到上一页 需要最后一个的值
            NSMutableDictionary *dic=[self.dataArray objectAtIndex:indexPath.row-1];
            NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
            [dataDic setObject:[dic objectForKey:@"name"] forKey:@"name"];
            [dataDic setObject:[dic objectForKey:@"uuid"] forKey:@"uuid"];
            [dataDic setObject:[NSString stringWithFormat:@"%d",[[dic objectForKey:@"order_no"] integerValue]] forKey:@"order_no"];
            
            NSString * isEdit=[NSString stringWithFormat:@"%d",[[dic objectForKey:@"is_completed"] integerValue]];
            [dataDic setObject:isEdit forKey:@"isEdit"];
            
            if (self.gotoIdeaEdit) {
                self.gotoIdeaEdit(num,dataDic,self.dataArray);
                
            }
  
    }

}
   
}
#pragma mark 异常汇总界面
- (UIView*)headView{
    UIView *headView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 88)];
    headView.backgroundColor=[UIColor whiteColor];
    UIView *unusualView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 44)];
    unusualView.backgroundColor=[UIColor whiteColor];
    [headView addSubview:unusualView];
    UILabel*unusualLab=[[UILabel alloc]initWithFrame:CGRectMake(25, 0.5, WindowWidth-30, 44-1)];
    unusualLab.textColor=MainColor;
    unusualLab.font=F(15);
    unusualLab.text=@"异常汇总";
    unusualLab.userInteractionEnabled=YES;
    [unusualView addSubview:unusualLab];
    UILabel* line1=[[UILabel alloc]initWithFrame:CGRectMake(0,0, WindowWidth, 0.5)];
    line1.backgroundColor=LineColor;
    [unusualView addSubview:line1];
    UILabel* line2=[[UILabel alloc]initWithFrame:CGRectMake(0,44-0.5, WindowWidth, 0.5)];
    line2.backgroundColor=LineColor;
    [unusualView addSubview:line2];
    [unusualView bk_whenTapped:^{
        
        NSString * unusualNum=@"1";//有异常为1没有异常为0
        
        //为了跳转到下一页 需要第一个的值
        NSMutableDictionary *dic=[self.dataArray objectAtIndex:0];
        NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
        [dataDic setObject:[dic objectForKey:@"name"] forKey:@"name"];
        [dataDic setObject:[dic objectForKey:@"uuid"] forKey:@"uuid"];
        [dataDic setObject:[NSString stringWithFormat:@"%d",[[dic objectForKey:@"order_no"] integerValue]] forKey:@"order_no"];
        
        if (self.gotoUnuaual) {
            self.gotoUnuaual(unusualNum,dataDic,self.dataArray);
        }
    }];
    UIView *centerView=[[UIView alloc]initWithFrame:CGRectMake(0, 44, WindowWidth, 44)];
    centerView.backgroundColor=BackColor;
    [headView addSubview:centerView];

    
    UILabel*Lab=[[UILabel alloc]initWithFrame:CGRectMake(25, 0.5, WindowWidth-30, 44-1)];
    Lab.textColor=FontColor;
    Lab.font=F(12);
    [centerView addSubview:Lab];
    Lab.text=@"完整报告";
    UILabel* line3=[[UILabel alloc]initWithFrame:CGRectMake(0,44-0.5, WindowWidth, 0.5)];
    line3.backgroundColor=LineColor;
    [centerView addSubview:line3];
    return headView;
}
- (UIView*)headView1
{
    UIView *headView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 30)];
    headView.backgroundColor=BackColor;
    UILabel*Lab=[[UILabel alloc]initWithFrame:CGRectMake(25, 0.5, WindowWidth-30, 30-1)];
    Lab.textColor=FontColor;
    Lab.font=F(12);
    [headView addSubview:Lab];
    Lab.text=@"完整报告";
    UILabel* line3=[[UILabel alloc]initWithFrame:CGRectMake(0,30-0.5, WindowWidth, 0.5)];
    line3.backgroundColor=LineColor;
    [headView addSubview:line3];
    return headView;
}

#pragma mark 开始巡检界面
-(void)createStartView
{
    _startView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 300)];
    _startView.backgroundColor=[UIColor whiteColor];
    [self addSubview:_startView];
    UILabel *nameLab=[[UILabel alloc]initWithFrame:CGRectMake(25, 15, _startView.bounds.size.width-50, 20)];
    nameLab.text=@"巡检作业程序";
    nameLab.textColor=C(@"5a5a5a");
    nameLab.font=F(15);
    [_startView addSubview:nameLab];
    NSString *context=[NSString stringWithFormat:@"1.准备工作：准备机房等相关资料，确认机房外部环境运行正常。\n2.进入机房：严格执行机房管理制度进出机房。\n3.物理环境检查：查看服务器设备、网络设备、环境设备等物理状态，设备状态指示灯、显示面板等。\n4.工作结束：退出机房锁门，整理巡检报告数据。"];
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:context];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
    [paragraphStyle setLineSpacing:5];//调整行间距
    
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [context length])];
   CGSize  labelsize = [context sizeWithFont:F(12) constrainedToSize:CGSizeMake(_startView.bounds.size.width-50, 900)];

    UILabel *contextLab=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(nameLab.frame)+5, _startView.bounds.size.width-50, labelsize.height+5*7)];
    contextLab.attributedText = attributedString;
    contextLab.textColor=C(@"5a5a5a");
    contextLab.font=F(12);
    contextLab.numberOfLines=0;
    [_startView addSubview:contextLab];
    //接单按钮
    UIButton* jiedanBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    [_startView addSubview:jiedanBtn];
    jiedanBtn.frame=CGRectMake(29, CGRectGetMaxY(contextLab.frame)+30, WindowWidth-58, 40);
    [jiedanBtn setBackgroundColor:MainColor];
    jiedanBtn.layer.masksToBounds=YES;
    jiedanBtn.layer.cornerRadius=8;
    [jiedanBtn setTitle:@"接单" forState:UIControlStateNormal];
    //开始巡检按钮
    UIButton* startBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    [_startView addSubview:startBtn];
    startBtn.frame=CGRectMake(29, CGRectGetMaxY(contextLab.frame)+30, WindowWidth-58, 40);
    [startBtn setBackgroundColor:MainColor];
    startBtn.layer.masksToBounds=YES;
    startBtn.layer.cornerRadius=8;
    [startBtn setTitle:@"开始巡检" forState:UIControlStateNormal];
    if (self.stateNum==1) {
        jiedanBtn.hidden=NO;
        startBtn.hidden=YES;
    }else if(self.stateNum==2)
    {
        jiedanBtn.hidden=YES;
        startBtn.hidden=NO;
    }
    [jiedanBtn bk_addEventHandler:^(id sender) {
      
        NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
        [dic setObject:self.Uuid forKey:@"uuid"];
        
        [CClass HttpRequestTask:YES withUrl:@"inspection_accept" withData:dic notifyError:YES onSuccess:^(BaseModel *model) {
            [[LoadingView shareLoading] stopAnimating];
            
            [CClass showLittleTimeMessage:@"接单成功" completion:nil];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"acceptPolling" object:nil];
            jiedanBtn.hidden=YES;
            startBtn.hidden=NO;

            
        } onError:^(BaseModel *model) {
            [[LoadingView shareLoading] stopAnimating];

        }];
        
    } forControlEvents:UIControlEventTouchUpInside];


    [startBtn bk_addEventHandler:^(id sender) {
        //开始巡检
        NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
        [dic setObject:self.Uuid forKey:@"uuid"];
        [CClass HttpRequestTask:YES withUrl:@"inspection_start" withData:dic notifyError:YES onSuccess:^(BaseModel *model) {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"startPolling" object:nil];
            [_startView removeFromSuperview];
            self.stateNum=10;//变成处理中
            [self createListView];
            [CClass showMessage:@"已开始巡检" completion:^{
                
            }];
        } onError:^(BaseModel *model) {
            
        }];
        
    } forControlEvents:UIControlEventTouchUpInside];
            

    UIView*bgView=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(startBtn.frame)+30, WindowWidth, 10)];
    bgView.backgroundColor=BackColor;
    [_startView addSubview:bgView];
  
   UIView* downView=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(bgView.frame), WindowWidth, 75)];
    downView.backgroundColor=[UIColor whiteColor];
    [_startView addSubview:downView];
    
    UILabel*lab=[[UILabel alloc]initWithFrame:CGRectMake(25, 15, 65, 15)];
    [downView addSubview:lab];
    lab.text =@"巡检单号";
    lab.textColor =FontColor;
    lab.font =FF(14);
    
    UILabel*numLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), 15, WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:numLab];
    numLab.text =self.code;
    numLab.textColor =LightFontColor;
    numLab.font =FF(14);
    
    NSString *inst=self.instName;
    CGSize labelsize1 = [inst sizeWithFont:FF(14) constrainedToSize:CGSizeMake(WindowWidth-15-65, 900)];
    
    UILabel*lab4=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(numLab.frame)+15, 65, 15)];
    [downView addSubview:lab4];
    lab4.text =@"巡检机构";
    lab4.textColor =FontColor;
    lab4.font =FF(14);
    
    UILabel*addressLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab4.frame), CGRectGetMaxY(numLab.frame)+15, WindowWidth-CGRectGetMaxX(lab4.frame), labelsize1.height)];
    [downView addSubview:addressLab];
    
    addressLab.textColor =LightFontColor;
    addressLab.font =FF(14);
    addressLab.numberOfLines=0;
    addressLab.userInteractionEnabled=YES;
    addressLab.text =inst;
    
   
    CGFloat height;
    if (self.moblieArray.count==0) {
        height=CGRectGetMaxY(addressLab.frame)+15;
    }else
    {
        UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(addressLab.frame)+15, 65,15)];
        [downView addSubview:label];
        label.text =@"联  系  人";
        label.textColor =FontColor;
        label.font =FF(14);
        for (int i=0; i<self.moblieArray.count; i++) {
            NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
            dic=[self.moblieArray objectAtIndex:i];
            UIView *phoneView=[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), CGRectGetMaxY(addressLab.frame)+30*i, WindowWidth-CGRectGetMaxX(lab.frame), 30)];
            [downView addSubview:phoneView];
            NSString *name=[NSString stringWithFormat:@"%@",[dic objectForKey:@"name"]];
            UILabel*phoneLab=[[UILabel alloc]init];
            phoneLab.frame=CGRectMake(0, 15, name.length*15, 15);
            [phoneView addSubview:phoneLab];
            phoneLab.text =name;
            phoneLab.textColor =MainColor;
            phoneLab.font =FF(14);
            phoneLab.userInteractionEnabled=YES;
            //接单显示
            UIImage*phoneImage=[UIImage imageNamed:@"Ico_home_detailPhone"];
            //电话按钮
            UIImageView*phoneImg=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(phoneLab.frame)+5, 30-phoneImage.size.height, phoneImage.size.width, phoneImage.size.height)];
            phoneImg.userInteractionEnabled=YES;
            phoneImg.image=phoneImage;
            [phoneView addSubview:phoneImg];
            
            [phoneView bk_whenTapped:^{
                [Common makePhoneWith:[dic objectForKey:@"mobile"]];
            }];
        }
        height=CGRectGetMaxY(addressLab.frame)+15+self.moblieArray.count*30;
        
    }
    

    downView.frame=CGRectMake(0, CGRectGetMaxY(bgView.frame), WindowWidth, height);
    _startView.frame=CGRectMake(0, 0, WindowWidth, CGRectGetMaxY(downView.frame));

}
#pragma mark     巡检单号 机构 开始时间 不能生成报告
//
- (UIView*)noProducefootTableView
{
    UIView*downView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 75)];
    downView.backgroundColor=[UIColor whiteColor];
    UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
    [downView addSubview:button];
    button.frame=CGRectMake(29,25, WindowWidth-58, 40);
    [button setBackgroundColor:C(@"cecbcb")];
    button.layer.masksToBounds=YES;
    button.layer.cornerRadius=8;
    [button setTitle:@"生成报告" forState:UIControlStateNormal];
    UIView *centerView=[[UIView alloc]initWithFrame:CGRectMake(0, 90, WindowWidth, 10)];
    centerView.backgroundColor=BackColor;
    [downView addSubview:centerView];
    UILabel*lab=[[UILabel alloc]initWithFrame:CGRectMake(25, 15+CGRectGetMaxY(centerView.frame), 65, 15)];
    [downView addSubview:lab];
    lab.text =@"巡检单号";
    lab.textColor =FontColor;
    lab.font =FF(14);

    UILabel*numLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), 15+CGRectGetMaxY(centerView.frame), WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:numLab];

    numLab.text =self.code;
    numLab.textColor =LightFontColor;
    numLab.font =FF(14);

    NSString *inst=self.instName;
    CGSize labelsize = [inst sizeWithFont:FF(14) constrainedToSize:CGSizeMake(WindowWidth-15-65, 900)];

    UILabel*lab4=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(numLab.frame)+15, 65, 15)];
    [downView addSubview:lab4];
    lab4.text =@"巡检机构";
    lab4.textColor =FontColor;
    lab4.font =FF(14);

    UILabel*addressLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab4.frame), CGRectGetMaxY(numLab.frame)+15, WindowWidth-CGRectGetMaxX(lab4.frame), labelsize.height)];
    [downView addSubview:addressLab];

    addressLab.textColor =LightFontColor;
    addressLab.font =FF(14);
    addressLab.numberOfLines=0;
    addressLab.userInteractionEnabled=YES;
    addressLab.text =inst;
    CGFloat height;
    if (self.moblieArray.count==0) {
        height=CGRectGetMaxY(addressLab.frame)+15;
    }else
    {
        UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(addressLab.frame)+15, 65,15)];
        [downView addSubview:label];
        label.text =@"联  系  人";
        label.textColor =FontColor;
        label.font =FF(14);
        for (int i=0; i<self.moblieArray.count; i++) {
            NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
            dic=[self.moblieArray objectAtIndex:i];
            UIView *phoneView=[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), CGRectGetMaxY(addressLab.frame)+30*i, WindowWidth-CGRectGetMaxX(lab.frame), 30)];
            [downView addSubview:phoneView];
            NSString *name=[NSString stringWithFormat:@"%@",[dic objectForKey:@"name"]];
            UILabel*phoneLab=[[UILabel alloc]init];
            phoneLab.frame=CGRectMake(0, 15, name.length*15, 15);
            [phoneView addSubview:phoneLab];
            phoneLab.text =name;
            phoneLab.textColor =MainColor;
            phoneLab.font =FF(14);
            phoneLab.userInteractionEnabled=YES;
            //接单显示
            UIImage*phoneImage=[UIImage imageNamed:@"Ico_home_detailPhone"];
            //电话按钮
            UIImageView*phoneImg=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(phoneLab.frame)+5, 30-phoneImage.size.height, phoneImage.size.width, phoneImage.size.height)];
            phoneImg.userInteractionEnabled=YES;
            phoneImg.image=phoneImage;
            [phoneView addSubview:phoneImg];
            
            [phoneView bk_whenTapped:^{
                [Common makePhoneWith:[dic objectForKey:@"mobile"]];
            }];
        }
        height=CGRectGetMaxY(addressLab.frame)+15+self.moblieArray.count*30;

    }
   
    UILabel*lab3=[[UILabel alloc]initWithFrame:CGRectMake(25, height, 65, 15)];
    [downView addSubview:lab3];
    lab3.text =@"开始时间";
    lab3.textColor =FontColor;
    lab3.font =FF(14);

    UILabel*startLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), height, WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:startLab];

    startLab.text =self.starTime;
    startLab.textColor =LightFontColor;
    startLab.font =FF(14);

    downView.frame=CGRectMake(0, 0, WindowWidth, CGRectGetMaxY(startLab.frame)+15);

    return downView;
}
#pragma mark     巡检单号 机构 开始时间 没有生成报告和生成报告 能生成
//
- (UIView*)producefootTableView
{
    UIView*downView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 75)];
    downView.backgroundColor=[UIColor whiteColor];
   
        UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
        [downView addSubview:button];
        button.frame=CGRectMake(29,25, WindowWidth-58, 40);
        [button setBackgroundColor:MainColor];
        button.layer.masksToBounds=YES;
        button.layer.cornerRadius=8;
        [button setTitle:@"生成报告" forState:UIControlStateNormal];

        [button bk_addEventHandler:^(id sender) {
      //11被退回 10待生成 处理中
                
            
            NSString *num=[NSString stringWithFormat:@"%d",self.stateNum];
            NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
//            NSMutableArray *parameterAr=[[NSMutableArray alloc]init];
            
//            for (int i=0; i<self.moblieArray.count; i++) {
//                NSMutableDictionary *dataDic=[self.moblieArray objectAtIndex:i];
//                NSMutableDictionary *upDic=[[NSMutableDictionary alloc]init];
//                [upDic setObject:[dataDic objectForKey:@"name"] forKey:@"name"];
//                [upDic setObject:[dataDic objectForKey:@"mobile"]  forKey:@"mobile"];
//                [parameterAr addObject:upDic];
//            }
            [dict setObject:self.moblieArray forKey:@"moblie"];
            [dict setObject:num forKey:@"stateNum"];
            [dict setObject:self.Uuid forKey:@"Uuid"];
            
            
            if (self.gotoProduce) {
                self.gotoProduce(dict);
            }

        } forControlEvents:UIControlEventTouchUpInside];
    
    UIView *centerView=[[UIView alloc]initWithFrame:CGRectMake(0, 90, WindowWidth, 10)];
    centerView.backgroundColor=BackColor;
    [downView addSubview:centerView];
    UILabel*lab=[[UILabel alloc]initWithFrame:CGRectMake(25, 15+CGRectGetMaxY(centerView.frame), 65, 15)];
    [downView addSubview:lab];
    lab.text =@"巡检单号";
    lab.textColor =FontColor;
    lab.font =FF(14);
    
    UILabel*numLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), 15+CGRectGetMaxY(centerView.frame), WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:numLab];
    
    numLab.text =self.code;
        numLab.textColor =LightFontColor;
    numLab.font =FF(14);
    
    NSString *inst=self.instName;
    CGSize labelsize = [inst sizeWithFont:FF(14) constrainedToSize:CGSizeMake(WindowWidth-15-65, 900)];
    
    UILabel*lab4=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(numLab.frame)+15, 65, 15)];
    [downView addSubview:lab4];
    lab4.text =@"巡检机构";
    lab4.textColor =FontColor;
    lab4.font =FF(14);
    
    UILabel*addressLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab4.frame), CGRectGetMaxY(numLab.frame)+15, WindowWidth-CGRectGetMaxX(lab4.frame), labelsize.height)];
    [downView addSubview:addressLab];
    
    addressLab.textColor =LightFontColor;
    addressLab.font =FF(14);
    addressLab.numberOfLines=0;
    addressLab.userInteractionEnabled=YES;
    addressLab.text =inst;
 
    CGFloat height;
    if (self.moblieArray.count==0) {
        height=CGRectGetMaxY(addressLab.frame)+15;
    }else
    {
        UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(addressLab.frame)+15, 65,15)];
        [downView addSubview:label];
        label.text =@"联  系  人";
        label.textColor =FontColor;
        label.font =FF(14);
        for (int i=0; i<self.moblieArray.count; i++) {
            NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
            dic=[self.moblieArray objectAtIndex:i];
            UIView *phoneView=[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), CGRectGetMaxY(addressLab.frame)+30*i, WindowWidth-CGRectGetMaxX(lab.frame), 30)];
            [downView addSubview:phoneView];
            NSString *name=[NSString stringWithFormat:@"%@",[dic objectForKey:@"name"]];
            UILabel*phoneLab=[[UILabel alloc]init];
            phoneLab.frame=CGRectMake(0, 15, name.length*15, 15);
            [phoneView addSubview:phoneLab];
            phoneLab.text =name;
            phoneLab.textColor =MainColor;
            phoneLab.font =FF(14);
            phoneLab.userInteractionEnabled=YES;
            //接单显示
            UIImage*phoneImage=[UIImage imageNamed:@"Ico_home_detailPhone"];
            //电话按钮
            UIImageView*phoneImg=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(phoneLab.frame)+5, 30-phoneImage.size.height, phoneImage.size.width, phoneImage.size.height)];
            phoneImg.userInteractionEnabled=YES;
            phoneImg.image=phoneImage;
            [phoneView addSubview:phoneImg];
            
            [phoneView bk_whenTapped:^{
                [Common makePhoneWith:[dic objectForKey:@"mobile"]];
            }];
        }
        height=CGRectGetMaxY(addressLab.frame)+15+self.moblieArray.count*30;
        
    
    }
    UILabel*lab3=[[UILabel alloc]initWithFrame:CGRectMake(25, height, 65, 15)];
    [downView addSubview:lab3];
    lab3.text =@"开始时间";
    lab3.textColor =FontColor;
    lab3.font =FF(14);
    
    UILabel*startLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), height, WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:startLab];
    
    startLab.text =self.starTime;
    
    //    }
    startLab.textColor =LightFontColor;
    startLab.font =FF(14);
    
    downView.frame=CGRectMake(0, 0, WindowWidth, CGRectGetMaxY(startLab.frame)+15);
    
    return downView;
}

#pragma mark     已生成报告，等待客户确认 待确认
//
- (UIView*)confirmFootTableView
{
    UIView*downView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 75)];
    downView.backgroundColor=[UIColor whiteColor];
    UILabel *sucessLab =[[UILabel alloc]initWithFrame:CGRectMake(0, 25, WindowWidth, 40)];
    [downView addSubview:sucessLab];
    sucessLab.text=@"已生成报告，等待客户确认";
    sucessLab.font=F(15);
    sucessLab.textAlignment=NSTextAlignmentCenter;
    sucessLab.textColor=FontColor;
    UIView *centerView=[[UIView alloc]initWithFrame:CGRectMake(0, 90, WindowWidth, 10)];
    centerView.backgroundColor=BackColor;
    [downView addSubview:centerView];
    UILabel*lab=[[UILabel alloc]initWithFrame:CGRectMake(25, 15+CGRectGetMaxY(centerView.frame), 65, 15)];
    [downView addSubview:lab];
    lab.text =@"巡检单号";
    lab.textColor =FontColor;
    lab.font =FF(14);
    
    UILabel*numLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), 15+CGRectGetMaxY(centerView.frame), WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:numLab];
  
    numLab.text =self.code;

    numLab.textColor =LightFontColor;
    numLab.font =FF(14);
    
    NSString *inst=self.instName;
    CGSize labelsize = [inst sizeWithFont:FF(14) constrainedToSize:CGSizeMake(WindowWidth-15-65, 900)];
    
    UILabel*lab4=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(numLab.frame)+15, 65, 15)];
    [downView addSubview:lab4];
    lab4.text =@"巡检机构";
    lab4.textColor =FontColor;
    lab4.font =FF(14);
    
    UILabel*addressLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab4.frame), CGRectGetMaxY(numLab.frame)+15, WindowWidth-CGRectGetMaxX(lab4.frame), labelsize.height)];
    [downView addSubview:addressLab];
    
    addressLab.textColor =LightFontColor;
    addressLab.font =FF(14);
    addressLab.numberOfLines=0;
    addressLab.userInteractionEnabled=YES;
    addressLab.text =inst;
    
    CGFloat height;
    if (self.moblieArray.count==0) {
        height=CGRectGetMaxY(addressLab.frame)+15;
    }else
    {
        UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(addressLab.frame)+15, 65,15)];
        [downView addSubview:label];
        label.text =@"联  系  人";
        label.textColor =FontColor;
        label.font =FF(14);
        for (int i=0; i<self.moblieArray.count; i++) {
            NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
            dic=[self.moblieArray objectAtIndex:i];
            UIView *phoneView=[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), CGRectGetMaxY(addressLab.frame)+30*i, WindowWidth-CGRectGetMaxX(lab.frame), 30)];
            [downView addSubview:phoneView];
            NSString *name=[NSString stringWithFormat:@"%@",[dic objectForKey:@"name"]];
            UILabel*phoneLab=[[UILabel alloc]init];
            phoneLab.frame=CGRectMake(0, 15, name.length*15, 15);
            [phoneView addSubview:phoneLab];
            phoneLab.text =name;
            phoneLab.textColor =MainColor;
            phoneLab.font =FF(14);
            phoneLab.userInteractionEnabled=YES;
            //接单显示
            UIImage*phoneImage=[UIImage imageNamed:@"Ico_home_detailPhone"];
            //电话按钮
            UIImageView*phoneImg=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(phoneLab.frame)+5, 30-phoneImage.size.height, phoneImage.size.width, phoneImage.size.height)];
            phoneImg.userInteractionEnabled=YES;
            phoneImg.image=phoneImage;
            [phoneView addSubview:phoneImg];
            
            [phoneView bk_whenTapped:^{
                [Common makePhoneWith:[dic objectForKey:@"mobile"]];
            }];
        }
        height=CGRectGetMaxY(addressLab.frame)+15+self.moblieArray.count*30;
        

    }
    UILabel*lab3=[[UILabel alloc]initWithFrame:CGRectMake(25, height, 65, 15)];
    [downView addSubview:lab3];
    lab3.text =@"开始时间";
    lab3.textColor =FontColor;
    lab3.font =FF(14);
    
    UILabel*startLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), height, WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:startLab];
    
    startLab.text =self.starTime;

    startLab.textColor =LightFontColor;
    startLab.font =FF(14);
    
    downView.frame=CGRectMake(0, 0, WindowWidth, CGRectGetMaxY(startLab.frame)+15);
    
    return downView;
}

#pragma mark     巡检单号 机构 开始时间 结束时间 待评级和已完成

-(UIView*)completeFootView
{
    //
    UIView *downView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 75)];
    downView.backgroundColor=[UIColor whiteColor];
    
    UIView *centerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 10)];
    centerView.backgroundColor=BackColor;
    [downView addSubview:centerView];

    UILabel*lab=[[UILabel alloc]initWithFrame:CGRectMake(25, 15+CGRectGetMaxY(centerView.frame), 65, 15)];
    [downView addSubview:lab];
    lab.text =@"巡检单号";
    lab.textColor =FontColor;
    lab.font =FF(14);
    
    UILabel*numLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame),  15+CGRectGetMaxY(centerView.frame), WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:numLab];
    numLab.text =self.code;
    numLab.textColor =LightFontColor;
    numLab.font =FF(14);
    
    NSString *inst=self.instName;
    CGSize labelsize = [inst sizeWithFont:FF(14) constrainedToSize:CGSizeMake(WindowWidth-15-65, 900)];
    
    UILabel*lab2=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(numLab.frame)+15, 65, 15)];
    [downView addSubview:lab2];
    lab2.text =@"巡检机构";
    lab2.textColor =FontColor;
    lab2.font =FF(14);
    
    UILabel*addressLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab2.frame), CGRectGetMaxY(numLab.frame)+15, WindowWidth-CGRectGetMaxX(lab2.frame), labelsize.height)];
    [downView addSubview:addressLab];
    
    addressLab.textColor =LightFontColor;
    addressLab.font =FF(14);
    addressLab.numberOfLines=0;
    addressLab.userInteractionEnabled=YES;
    addressLab.text =inst;
    CGFloat height;
    if (self.moblieArray.count==0) {
        height=CGRectGetMaxY(addressLab.frame)+15;
    }else
    {
        UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(addressLab.frame)+15, 65,15)];
        [downView addSubview:label];
        label.text =@"联  系  人";
        label.textColor =FontColor;
        label.font =FF(14);
        for (int i=0; i<self.moblieArray.count; i++) {
            NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
            dic=[self.moblieArray objectAtIndex:i];
            UIView *phoneView=[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), CGRectGetMaxY(addressLab.frame)+30*i, WindowWidth-CGRectGetMaxX(lab.frame), 30)];
            [downView addSubview:phoneView];
            NSString *name=[NSString stringWithFormat:@"%@",[dic objectForKey:@"name"]];
            UILabel*phoneLab=[[UILabel alloc]init];
            phoneLab.frame=CGRectMake(0, 15, name.length*15, 15);
            [phoneView addSubview:phoneLab];
            phoneLab.text =name;
            phoneLab.textColor =MainColor;
            phoneLab.font =FF(14);
            phoneLab.userInteractionEnabled=YES;
            //接单显示
            UIImage*phoneImage=[UIImage imageNamed:@"Ico_home_detailPhone"];
            //电话按钮
            UIImageView*phoneImg=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(phoneLab.frame)+5, 30-phoneImage.size.height, phoneImage.size.width, phoneImage.size.height)];
            phoneImg.userInteractionEnabled=YES;
            phoneImg.image=phoneImage;
            [phoneView addSubview:phoneImg];
            
            [phoneView bk_whenTapped:^{
                [Common makePhoneWith:[dic objectForKey:@"mobile"]];
            }];
        }
        height=CGRectGetMaxY(addressLab.frame)+15+self.moblieArray.count*30;
        

    }
    UILabel*lab3=[[UILabel alloc]initWithFrame:CGRectMake(25, height, 65,15)];
    [downView addSubview:lab3];
    lab3.text =@"开始时间";
    lab3.textColor =FontColor;
    lab3.font =FF(14);
    
    UILabel*startLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab.frame), height, WindowWidth-CGRectGetMaxX(lab.frame), 15)];
    [downView addSubview:startLab];
    
    startLab.text =self.starTime;

    startLab.textColor =LightFontColor;
    startLab.font =FF(14);
    
    UILabel*lab4=[[UILabel alloc]initWithFrame:CGRectMake(25, CGRectGetMaxY(startLab.frame)+15,65, 15)];
    [downView addSubview:lab4];
    lab4.text =@"结束时间";
    lab4.textColor =FontColor;
    lab4.font =FF(14);
    
    UILabel*endLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lab4.frame), CGRectGetMaxY(startLab.frame)+15, WindowWidth-CGRectGetMaxX(lab4.frame), 15)];
    [downView addSubview:endLab];
    
    endLab.text =self.endTime;

    endLab.textColor =LightFontColor;
    endLab.font =FF(14);
    
    downView.frame=CGRectMake(0,0, WindowWidth, CGRectGetMaxY(endLab.frame)+15);
    return downView;
}


@end
